<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="./header.jsp" %>

<head> 
	<style>
		.goods-area{
			display: none;
		}
		
		.hot-box{
			margin-top:20px;margin-left:0px;margin-right:0px;background:#F2F2F2;border:3px solid #DDDDDB;
		}
		
		.hot-box:hover{
			border:3px solid #ff5500;
		}
		
		.categorys{
			float:left;
		}
		
		.categorys li{
			float: left;
			list-style: none;
			margin-right:10px;
		}
		.categorys li a{
			line-height: 75px;
			height:75px;
			display: block;
			color:#093;
			text-decoration: none;
		}
	</style>
	
</head>

<body class="grayback">
	<!-- begin公告 -->
	<div class="panel panel-info" id="announcement" style="display:none;width:200px;position: absolute;top:55px;left:0px;z-index:100;">      
	     <div class="panel-heading">
	      <h3 class="panel-title">公告</h3>
	      <span class="glyphicon glyphicon-remove" id="close_announcement_id" style="position: absolute;top:10px;left:172px;cursor:pointer;"></span>     
	    </div>
	    <div class="panel-body"> 
	      	
	    </div>
	</div>
	<!-- end公告 -->
	<tags:top/>
	
	<div class="bs-example">
      <div id="carousel-example-captions" class="carousel slide" data-ride="carousel">
         
        <div class="carousel-inner">
          <div class="item active">
          	<a href="${ctx}/discount/#名鞋专场" target="_blank"><img data-src="holder.js/900x500/auto/#777:#777" alt="900x500" src="https://img.alicdn.com/imgextra/i2/914260183/TB2b5WycXXXXXcoXpXXXXXXXXXX_!!914260183.jpg"></a>
            <div class="carousel-caption">
              <h3 style="color:#F97;"></h3>
              <p></p>
            </div>
          </div>
          
          
        </div>
<!--          <a class="left carousel-control" href="#carousel-example-captions" data-slide="prev"> -->
<!--           <span class="glyphicon glyphicon-chevron-left"></span> -->
<!--         </a> -->
<!--         <a class="right carousel-control" href="#carousel-example-captions" data-slide="next"> -->
<!--           <span class="glyphicon glyphicon-chevron-right"></span> -->
<!--         </a> -->
      </div>
    </div>

    <div class="container"  id="goods_main_id">
		<!-- begin 人气单品专区 -->
		
<!-- 		<div style="color:red;font-size:30px;line-height:40px;margin-top:10px;"> -->
<!-- 			至广大客户：我们客服只会电话和短信核实订单信息，别的电话都是骗子请客户们不要相信！ -->
<!-- 		</div> -->
		<div id="hot_area_id">
			<div style="color:#666;font-weight: bold;margin-top:20px;border-bottom:1px solid #ccc;">
	  			<div style="height:40px;width:160px;background: url('${ctx}/images/jrms.png');"><span style="height:0px;font-size:0px;">人气单品</span>
	  			</div>
			</div>
			
		<div class="row hot-box" id="hot_model_id" style="display: none;">
		
				<div class="col-md-6">
		    	<div class="thumbnail" style="">
		    		<a href="#" class="img-a" target="_blank"><img alt="" class="img-box" src=""></a>
		    	</div>
		      	  
	  		</div>
	  			<div class="col-md-6" style="">
			    <div><a href="#" class="title-a"  style="font-size:22px;color:#000;font-weight: bold;text-decoration: none;" target="_blank"></a></div>
			    
			     <div class="buy" style="margin-bottom:10px;margin-top:20px;">
			     		<div style="border-radius:5px;background-image: url('${ctx}/images/chuxiao-bg.png');">
			     			<div class="row">
			     				<div  class="col-md-8 col-sm-8 col-xs-12" >
			     					<span style="color:#fff;padding-left:10px;">今日促销价：</span>
			     					<span style="color:#fff;font-size:34px;" class="nowprice"></span>
			     				</div>
			     				<div class="col-md-4 col-sm-4 col-xs-12"  style="padding-top:5px;padding-bottom:5px;padding-left:20px;">
			     					<a type="button" id="register_btn" data-buy="yes" class="btn btn-lg btn-qg"     href="#" target="_blank">立即抢购</a>
			     				</div>
			     			</div>
			     		</div>
			    </div>
			    
			    <div class="infobox" >
			    	<div style="font-size:20px; text-decoration:line-through;">
	            		<span style="color:#999;">原价：</span>
	           			<span class="oldprice num" id="oldprice"></span>                      
                	</div>
			    	<div style="font-size:20px;">
			    		<span style="color:#999;">最近30天已售：</span>
			    		<span style="color:#5cb85c;font-size:36px;font-weight: bold;"  id="lastsale_id" class="buy-num"></span>
			    	</div>
			    	
			    	<div style="font-size:20px;">
			    		<span style="color:#999;">好评如潮：</span>
			    		<span style="color:#5cb85c;"  id="comment_id"></span>
			    	</div>
			    	
			    	<div style="font-size:20px;display: none;margin-top:5px;" id="timer_div">
			    		<span style="color:#999;">团购倒计时：</span>
			    		<span style="color:red;"  id="timer_id"></span>
			    	</div>
			    </div>
			    
			    <div style="margin-top:15px;display: none;" id="recommend_div">
			    	<div style="color:#5cb85c;font-size:20px;">
			    		名鞋团购网推荐理由：
			    	</div>
			    	<div style="font-size:16px;color:#999;" class="recommend"> 
			    	</div>
			    </div>
			    
			     <div style="margin-top:15px;display: none;" id="scene_div">
			    	<div style="color:#5cb85c;font-size:20px;">
			    		适合场景：
			    	</div>
			    	<div style="font-size:16px;color:#999;" class="scene"> 
			    	</div>
			    </div>
			    
			    <div style="margin-top:15px;margin-bottom:10px;display: none;" id="tips_div" > 
			    	<div style="color:#999;font-size:20px;">
			    		温馨提示：
			    	</div>
			    	<div style="font-size:16px;color:#D9534F;font-weight: bold;" class="tips"> 
			    	</div>
			    </div>
	            
	  		</div>
	  		
	  		
	  		
  		</div>
  		
 
		</div>
			
		<!-- end 人气单品专区 -->
		
		<!-- begin 折扣专场 -->
		<div class="goods-area">
			<div style="color:#666;font-weight: bold;margin-top:10px;margin-left:-5px;border-bottom:1px solid #ccc;">
  				<div style="height:40px;width:200px;background: url('${ctx}/images/mxzkzc.png') "><span style="height:0px;font-size:0px;">名鞋折扣专场</span></div>
			</div>
			
			<div id="brands_img_div_top" class="clearfix">
		   		<ul class="brands" style="float: left;">
		    		<li id="brands_img_model_id" style="display: none;">
		    			<a href="#" target="_blank">
			    			<img src="${ctx }/images/nike.jpg"/>
			    			<div class="bg" ></div>
		    			</a>
		    		</li>
		    	</ul>
		    	
		    	<ul class="categorys">
		    		
		    	</ul>
			</div>
			
			<div style="margn-top:5px;">
				<a href="${ctx }/discount/#名鞋专场" target="_blank" style="color:#ff5500; font-size:24px;">更多团购...</a>
			</div>
			
			<div class="row" id="goods_new_div">
	    		<!-- col1 -->
			    <div class="col-sm-4 col-md-4" id="col_id0">
					    	
		  		</div>
		  		
		  		<!-- col2 -->
		  		<div class="col-sm-4 col-md-4" id="col_id1">
					    	
		  		</div>
		  		
		  		<!-- col3 -->
		  		<div class="col-sm-4 col-md-4" id="col_id2">
					    	
		  		</div>
    		</div>
			
			<div style="margn-top:5px;" align="right">
				<a href="${ctx }/discount/?cur=2#名鞋专场" target="_blank" style="color:#ff5500;font-size:24px;">更多团购...</a>
			</div>
			
		<div id="brands_img_div_bottom">
				<h5 class="model-title" style="margin-bottom:0px;width:130px;">更多品牌推荐：</h5>
	    </div>
		
		</div>
		<!-- end 折扣专场 -->
    </div>
    
    <!-- begin model -->
	    <div class="thumbnail shopbox" id="goods_new_model" style="display: none;">
	      <div style="width:56px;height:24px;position: absolute;z-index:30;top: 0px;right:0px;background: url('${ctx}/images/hot.png') no-repeat;"></div>
	     	  <a href="#" class="img-a" target="_blank"><img alt="" src="${ctx }/images/loading.gif"></a>
	      
	      <div class="caption">
	        <a href="#" target="_blank" class="title-a" style="text-decoration: none;"><h6 class="title ellipsis" style="color:#666;"></h6></a>
	        
	        <p class="content" style="margin:0px;">
	        	<strong class="nowprice" style="color:#F76120;font-size:20px;font-weight: bold;height: 31px;line-height: 31px;"></strong>
	        	<span class="oldprice" style="color:#9F9F9F;font-size:14px;text-decoration:line-through;"></span>
	        	<span style="background: #ff5500;color:#FFF;font-size:14px;">货到付款</span>
	        </p>
	        
	        <div align="" style="margin-bottom:5px;">
	        	<span style="font-size:12px;color:#666;"><span class="buy-num" style="padding-right:5px;"></span>人已经购买</span>
	        </div>
	        <p align=""><a href="#" target="_blank" class="btn btn-buy btn-block" role="button">立即抢购</a></p>
	      </div>
	      
	  	</div>
  	<!-- end model -->
  	
	
	<tags:bottom/>
	<script>
		$(function(){
				var sh; 
				var col = 3;
				//获取人气单品
				jQuery.ajax({
					type : 'Get',
					contentType : 'application/json',
					url : "${ctx}/goods/hotList.do?pageSize=8&grade=5&currPage=1&categoryId=0",
					async:false,
					dataType : 'json',
					success:function(dataObj){
			        	var list = dataObj.obj.goodsList;
			        	var commentList = dataObj.obj.commentList;
			        	for(var i = 0 ;i<list.length;i++){
			        		var colDiv = $("#hot_area_id");
								var model = $("#hot_model_id").clone();
				        		model.attr("id","");
				        		var goods = list[i];
				        		var commentCount = commentList[i];
				        		var price = goods.price;
								model.find("img").attr("src","./upload/download.do?fileName="+goods.picName).attr("title",goods.title).attr("alt",goods.title);
				            	model.find(".img-a").attr("href","${ctx}/detailGoods/"+goods.id);
		            			model.find(".title-a").attr("href","${ctx}/detailGoods/"+goods.id).html(goods.title+"<span style='color:#5cb85c;'>（货到付款、顺丰包邮）</span>");
				            	model.find(".btn-qg").attr("href","${ctx}/detailGoods/"+goods.id);
				            	if(goods.expiredDate){
				            		
				            		model.find("#timer_div").show();
				            		var jDom = model.find("#timer_id");
				            		if(i == 0){
				            			var jDom1 = $("#timer_total_id");
					            		sh=setInterval(_fresh(goods.expiredDate,jDom1),100);	
				            		}
				            		
				    				sh=setInterval(_fresh(goods.expiredDate,jDom),100); 
				            	}
				            
				            	
				            	model.find("#comment_id").html(commentCount+"个好评");
				            	model.find(".buy-num").html(goods.buyNum+"件");
				            	model.find(".nowprice").html("￥"+goods.nowPrice+".00");
				            	model.find(".oldprice").html("￥"+price+".00");
				            	if(goods.recommend){
				            		model.find("#recommend_div").show();
				            		model.find(".recommend").html("”"+goods.recommend+"”");
				            	}
				            	if(goods.scene){
				            		model.find("#scene_div").show();
				            		model.find(".scene").html(goods.scene);
				            	}
				            
				            	if(goods.tips){
				            		model.find("#tips_div").show();
				            		model.find(".tips").html(goods.tips);
				            	}
				            	
				            	model.show();
				            	colDiv.append(model);
			        	}
					}
				});
				
				//获取折扣专场
				jQuery.ajax({
					type : 'Get',
					contentType : 'application/json',
					url : "${ctx}/goods/goodsListByGrade.do?pageSize=48&currPage=1",
					async:false,
					dataType : 'json',
					success:function(dataObj){
			        	var list = dataObj.obj.goodsList;
			        	for(var i = 0 ;i<list.length;i++){
								var model = $("#goods_new_model").clone();
				        		model.attr("id","");
				        		var goods = list[i];
				        		var price = goods.price;
								model.find("img").attr("data-url","./upload/download.do?fileName="+goods.picName).attr("title",goods.title).attr("alt",goods.title);
								model.find(".img-a").attr("href","${ctx}/detailGoods/"+goods.id);
		            			model.find(".title-a").attr("href","${ctx}/detailGoods/"+goods.id);
				            	model.find(".title").html(goods.title);
				            	model.find(".btn").attr("href","${ctx}/detailGoods/"+goods.id);
				            	model.find(".buy-num").html(goods.buyNum);
				            	model.find(".nowprice").html("￥"+goods.nowPrice);
				            	model.find(".oldprice").html("￥"+price);
				            	model.show();
				            	$("#col_id"+i%col).append(model);
			        	}
			        	$("#goods_new_div").closest(".goods-area").show();
			        	$(".thumbnail img").scrollLoading();
					}
				});
				
				/**
				*倒计时函数
				**/
				function _fresh(date,jDom)  
				{  
				return function(){
					 var endtime=new Date(date);  
					 var nowtime = new Date();  
					 var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);  
					 __d=parseInt(leftsecond/3600/24);  
					 __h=parseInt((leftsecond/3600)%24);  
					 __m=parseInt((leftsecond/60)%60);  
					 __s=parseInt(leftsecond%60);  
					var c=new Date();
					var q=((c.getMilliseconds())%10);
					jDom.html(__d+"天 "+__h+"小时"+__m+"分"+__s+"."+q+"秒");
					 if(leftsecond<=0){  
					 jDom.html("抢购已结束");
					 clearInterval(sh);  
					 }  
				};
				}  
				
				//获取上架品牌
				jQuery.ajax({
					type : 'Get',
					contentType : 'application/json',
					url : '${ctx}/brands/getAlllAddOn.do',
					cache:true,
					async:false,
					data : {
					},
					dataType : 'json',
					success : function(data) {
						if (data.result) {
							var brandsList = data.obj;
							if(brandsList){
								var html = "";
								for(var i = 0 ;i<brandsList.length;i++){
									var brands = brandsList[i];
									if(brands){
									 
										//设置图片品牌分类
										var cloneLi = $("#brands_img_model_id").clone();
										cloneLi.find("a").attr("href",_ctx+"/discount/?brands="+brands.id+"#名鞋专场");
										cloneLi.find("img").attr("src",_ctx+"/upload/download.do?fileName="+brands.pic);
										$(".brands").append(cloneLi);
										cloneLi.show(); 
									}
								}
								$("#brands_img_div_bottom").append($("#brands_img_div_top").html());
							}
							
						} else {
							//alert('数据库异常,查询数据失败');
						}
					},
					error : function(data) {
					}
				});	
				
				//获取上架分类
				jQuery.ajax({
					type : 'Get',
					contentType : 'application/json',
					url : '${ctx}/category/getAlllAddOn.do',
					cache:true,
					async:false,
					dataType : 'json',
					success : function(data) {
						if (data.result) {
							var categoryList = data.obj;
							if(categoryList){
								var html = "";
								for(var i = 0 ;i<categoryList.length;i++){
									var category = categoryList[i];
									if(category)
										var li = '<li><a href="${ctx }/discount/?category='+category.id+'#名鞋专场" target="_blank">'+category.name+'</a></li>'; 
										html = html+li;
								}
								$(".categorys").append(html);
							}
							
						} else {
							//alert('数据库异常,查询数据失败');
						}
					},
					error : function(data) {
					}
				});	
				
				//公告管理
				jQuery.ajax( {
						type : 'Get',
						url : '${ctx}/announcement/getAnnouncement.do',
						dataType : 'json',
						contentType : 'application/json',
						async:false,
						success : function(data) {
							if(data.result){
								//后台设置为显示
								if(data.obj.isShow == 1){
									$("#announcement .panel-body").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+data.obj.content); 
									$("#announcement").fadeIn();	
								}
							}
						}
				});
				$("#close_announcement_id").click(function(){
					$("#announcement").fadeOut();
				});
		});
	</script>
	
</body>